package org.lemon.transport.context.service;

import com.google.protobuf.ByteString;
import org.lemon.transport.context.data.device.DeviceProfile;
import org.lemon.transport.context.service.DataDecodingEncodingService;
import org.lemon.transport.context.service.TransportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

@Component
public class TransportDeviceProfileCache {

    private final Lock deviceProfileFetchLock = new ReentrantLock();
    //<DeviceProfileId, DeviceProfile>
    private final ConcurrentMap<Long, DeviceProfile> deviceProfiles = new ConcurrentHashMap<>();
    private final DataDecodingEncodingService dataDecodingEncodingService;

    private TransportService transportService;

    public TransportDeviceProfileCache(DataDecodingEncodingService dataDecodingEncodingService) {
        this.dataDecodingEncodingService = dataDecodingEncodingService;
    }

    @Lazy
    @Autowired
    public void setTransportService(TransportService transportService) {
        this.transportService = transportService;
    }

    public DeviceProfile getOrCreate(Long deviceProfileId, ByteString profileBody) {

        return null;
    }

    public DeviceProfile get(Long deviceProfileId) {

        return null;
    }

    public void put(DeviceProfile profile) {

    }

    public DeviceProfile put(ByteString profileBody) {

        return null;
    }

    public void evict(Long deviceProfileId) {

    }
}
